package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldAccountDetails;
import com.cleaningcloud.cld.service.ICldAccountDetailsService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 账户流水明细Controller
 * 
 * @author cleaningcloud
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/accountDetails")
public class CldAccountDetailsController extends BaseController
{
    @Autowired
    private ICldAccountDetailsService cldAccountDetailsService;

    /**
     * 查询账户流水明细列表
     */
    @RequiresPermissions("cld:accountDetails:list")
    @GetMapping("/list")
    public TableDataInfo list(CldAccountDetails cldAccountDetails)
    {
        startPage();
        List<CldAccountDetails> list = cldAccountDetailsService.selectCldAccountDetailsList(cldAccountDetails);
        return getDataTable(list);
    }

    /**
     * 导出账户流水明细列表
     */
    @RequiresPermissions("cld:accountDetails:export")
    @Log(title = "导出账户流水明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldAccountDetails cldAccountDetails)
    {
        List<CldAccountDetails> list = cldAccountDetailsService.selectCldAccountDetailsList(cldAccountDetails);
        ExcelUtil<CldAccountDetails> util = new ExcelUtil<CldAccountDetails>(CldAccountDetails.class);
        util.exportExcel(response, list, "账户流水明细数据");
    }

    /**
     * 获取账户流水明细详细信息
     */
    @RequiresPermissions("cld:accountDetails:query")
    @GetMapping(value = "/{accountDetailsId}")
    public AjaxResult getInfo(@PathVariable("accountDetailsId") Long accountDetailsId)
    {
        return success(cldAccountDetailsService.selectCldAccountDetailsByAccountDetailsId(accountDetailsId));
    }

    /**
     * 新增账户流水明细
     */
    @RequiresPermissions("cld:accountDetails:add")
    @Log(title = "新增银行流水明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldAccountDetails cldAccountDetails)
    {
        return toAjax(cldAccountDetailsService.insertCldAccountDetails(cldAccountDetails));
    }

    /**
     * 修改账户流水明细
     */
    @RequiresPermissions("cld:accountDetails:edit")
    @Log(title = "修改银行流水明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldAccountDetails cldAccountDetails)
    {
        return toAjax(cldAccountDetailsService.updateCldAccountDetails(cldAccountDetails));
    }

    /**
     * 删除账户流水明细
     */
    @RequiresPermissions("cld:accountDetails:remove")
    @Log(title = "删除银行流水明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{accountDetailsIds}")
    public AjaxResult remove(@PathVariable Long[] accountDetailsIds)
    {
        return toAjax(cldAccountDetailsService.deleteCldAccountDetailsByAccountDetailsIds(accountDetailsIds));
    }
}
